﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Data;
using SF.Common;
using SF.Model;
namespace SF.BLL
{
    //sf_door_templates
    public partial class sf_door_templates
    {

        private readonly SF.DAL.sf_door_templates dal = new SF.DAL.sf_door_templates();
        public sf_door_templates()
        { }

        #region  Method
        /// <summary>
        /// 是否存在该记录
        /// </summary>
        public bool Exists(long id)
        {
            return dal.Exists(id);
        }

        /// <summary>
        /// 增加一条数据
        /// </summary>
        public long Add(SF.Model.sf_door_templates model)
        {
            return dal.Add(model);

        }

        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(SF.Model.sf_door_templates model)
        {
            return dal.Update(model);
        }

        /// <summary>
        /// 删除一条数据
        /// </summary>
        public bool Delete(long id)
        {

            return dal.Delete(id);
        }
        /// <summary>
        /// 批量删除一批数据
        /// </summary>
        public bool DeleteList(string idlist)
        {
            return dal.DeleteList(idlist);
        }

        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public SF.Model.sf_door_templates GetModel(long id)
        {

            return dal.GetModel(id);
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetList(string strWhere)
        {
            return dal.GetList(strWhere);
        }
        /// <summary>
        /// 获得前几行数据
        /// </summary>
        public DataSet GetList(int Top, string strWhere, string filedOrder)
        {
            return dal.GetList(Top, strWhere, filedOrder);
        }
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<SF.Model.sf_door_templates> GetModelList(string strWhere)
        {
            DataSet ds = dal.GetList(strWhere);
            return DataTableToList(ds.Tables[0]);
        }
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<SF.Model.sf_door_templates> DataTableToList(DataTable dt)
        {
            List<SF.Model.sf_door_templates> modelList = new List<SF.Model.sf_door_templates>();
            int rowsCount = dt.Rows.Count;
            if (rowsCount > 0)
            {
                SF.Model.sf_door_templates model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new SF.Model.sf_door_templates();
                    if (dt.Rows[n]["id"].ToString() != "")
                    {
                        model.id = long.Parse(dt.Rows[n]["id"].ToString());
                    }
                    model.templatesNum = dt.Rows[n]["templatesNum"].ToString();
                    model.imgs = dt.Rows[n]["imgs"].ToString();


                    modelList.Add(model);
                }
            }
            return modelList;
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetAllList()
        {
            return GetList("");
        }
        /// <summary>
        /// 获得查询分页数据
        /// </summary>
        public DataSet GetList(int pageSize, int pageIndex, string strWhere, string filedOrder, out int recordCount)
        {
            return dal.GetList(pageSize, pageIndex, strWhere, filedOrder, out recordCount);
        }
        #endregion

    }
}